Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

gh-141510: Support frozendict in plistlib#145590

Open
hugovk wants to merge 1 commit intopython:mainfrom
hugovk:3.15-frozendict-plistlib
Open

gh-141510: Support frozendict in plistlib#145590
hugovk wants to merge 1 commit intopython:mainfrom
hugovk:3.15-frozendict-plistlib

Conversation

@hugovk
Copy link
Member

@hugovk hugovk commented Mar 6, 2026

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@serhiy-storchaka @ronaldoussoren: Do you want to double check this plistlib change?

The property list (``.plist``) file format is a simple serialization supporting
basic object types, like dictionaries, lists, numbers and strings. Usually the
top level object is a dictionary.
top level object is a dictionary or frozen dictionary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native English speaker, but don't you have to repeat "a"?

Suggested change
top level object is a dictionary or frozen dictionary.
top level object is a dictionary or a frozen dictionary.

The property list (.plist) file format is a simple XML pickle supporting
basic object types, like dictionaries, lists, numbers and strings.
Usually the top level object is a dictionary.
Usually the top level object is a dictionary or frozen dictionary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native English speaker, but don't you have to repeat "a"?

Suggested change
Usually the top level object is a dictionary or frozen dictionary.
Usually the top level object is a dictionary or a frozen dictionary.

import plistlib

pl = dict(
pl = frozendict(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that using a frozendict is better than a dict for the only example generating a plist.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a NEWS entry. Note that support of frozendict is half-hearted -- only for serialization. dict_type=frozendict does not work in load(). I am not sure that it is worth to add support for deserialization.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstinner
Copy link
Member

Please add a NEWS entry. Note that support of frozendict is half-hearted -- only for serialization. dict_type=frozendict does not work in load(). I am not sure that it is worth to add support for deserialization.

I saw that and hesitated to propose a follow-up change to add frozendict support for deserialization. It should be possible to create a (mutable) dict, populate the dictionary, and then convert the dict to a frozendict.

@serhiy-storchaka
Copy link
Member

It should be possible to create a (mutable) dict, populate the dictionary, and then convert the dict to a frozendict.

This can add an overhead and this would not work in case of cyclic references in binary Plist.

Originally, dict_type was only added to support OrderedDict. Now, when dict is ordered, this parameter is mostly useless. If there was other use cases for this feature, we would need also an option to override the list type.

So, there is very little value in such feature, and it is very difficult to do without breaking corner cases. But this should be explicitly stated that frozendicts are supported only in one way (like tuple).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants